/**
 * @param {number} n
 * @return {string[]}
 */
var generateParenthesis = function(n) {
    const result =[];
    
    function backTrack(currentPath,left,right){
        
        if(currentPath.length===2*n){
            result.push(currentPath);
            return
        }
        
        if(left<n){
            backTrack(currentPath+'(',left+1,right)
        }

        if(right<left){
            backTrack(currentPath+')',left,right+1)
        }

    }

    backTrack('',0,0);
    return result;

};